#ifndef IALGORITHM_HEAD_H
#define IALGORITHM_HEAD_H
#include "comm.h"
struct IPLocation
{
	DWORD		start_int;
	DWORD		end_int;
	char *		county;
	char *		area;
	~IPLocation(){
		if ( area != NULL )
		{
			delete [] area ;
			area = NULL ;
		}
		if ( county != NULL )
		{
			delete [] county ;
			county = NULL ;
		}
	}
	IPLocation(){
		memset( this , 0 , sizeof(*this) );
	}
	void set_country( const char * coutry_){
		int len = strlen( coutry_ );
		county = new char [ len + 1 ];
		memcpy( county , coutry_ , len );
		county [ len ] = '\0';

	}
	const char * get_ip_address( DWORD ip ){
		in_addr in ;
		in.s_addr = htonl( ip ) ;
		return inet_ntoa ( in );
	}
	DWORD get_ip_uint(const char * srcip){
		return htonl(inet_addr(srcip));
	}
};

typedef std::vector< IPLocation *> VEC_IPS;

class IAlgorithm
{
public:

	IAlgorithm(void)
	{
	}
	virtual ~IAlgorithm(void)
	{
	}
public:
	virtual const char * find_area_name( DWORD ip , VEC_IPS & vec_start , VEC_IPS & vec_end ) = 0 ;
};


#endif


